
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.4 Less规范 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="性能优化.html" />
    
    
    <link rel="prev" href="模块组织.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../基本原则.html">
            
                <a href="../基本原则.html">
            
                    
                    1. 基本原则
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../html/HTML.html">
            
                <a href="../html/HTML.html">
            
                    
                    2. HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../html/通用约定.html">
            
                <a href="../html/通用约定.html">
            
                    
                    2.1 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../html/语义化.html">
            
                <a href="../html/语义化.html">
            
                    
                    2.2 语义化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../html/HEAD.html">
            
                <a href="../html/HEAD.html">
            
                    
                    2.3 HEAD
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="CSS.html">
            
                <a href="CSS.html">
            
                    
                    3. CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="通用约定.html">
            
                <a href="通用约定.html">
            
                    
                    3.1 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="字体排印.html">
            
                <a href="字体排印.html">
            
                    
                    3.2 字体排印
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="模块组织.html">
            
                <a href="模块组织.html">
            
                    
                    3.3 模块组织
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.4" data-path="Less规范.html">
            
                <a href="Less规范.html">
            
                    
                    3.4 Less规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="性能优化.html">
            
                <a href="性能优化.html">
            
                    
                    3.5 性能优化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../javascript/js.html">
            
                <a href="../javascript/js.html">
            
                    
                    4. JavaScript
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../javascript/通用约定.html">
            
                <a href="../javascript/通用约定.html">
            
                    
                    4.1. 通用约定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../javascript/jq.md">
            
                <span>
            
                    
                    4.2. jQuery 规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../javascript/性能优化.md">
            
                <span>
            
                    
                    4.3. 性能优化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../">
            
                <a href="../">
            
                    
                    5. 移动端优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../">
            
                <a href="../">
            
                    
                    6. 工具箱
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../">
            
                <a href="../">
            
                    
                    7. 参考
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3.4 Less规范</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="34-less&#x89C4;&#x8303;">3.4 Less&#x89C4;&#x8303;</h3>
<hr>
<p><strong>&#x4EE3;&#x7801;&#x7EC4;&#x7EC7;</strong></p>
<p>&#x4EE3;&#x7801;&#x6309;&#x4E00;&#x4E0B;&#x987A;&#x5E8F;&#x7EC4;&#x7EC7;&#xFF1A;</p>
<ol>
<li>@import</li>
<li>&#x53D8;&#x91CF;&#x58F0;&#x660E;</li>
<li>&#x6837;&#x5F0F;&#x58F0;&#x660E;</li>
</ol>
<pre><code>@import &quot;mixins/size.less&quot;;

@default-text-color: #333;

.page {
  width: 960px;
  margin: 0 auto;
}
</code></pre><p><strong>@import &#x8BED;&#x53E5;</strong></p>
<p>@import &#x8BED;&#x53E5;&#x5F15;&#x7528;&#x7684;&#x6587;&#x9700;&#x8981;&#x5199;&#x5728;&#x4E00;&#x5BF9;&#x5F15;&#x53F7;&#x5185;&#xFF0C;.less &#x540E;&#x7F00;&#x4E0D;&#x5F97;&#x7701;&#x7565;&#x3002;&#x5F15;&#x53F7;&#x4F7F;&#x7528; &apos; &#x548C; &quot; &#x5747;&#x53EF;&#xFF0C;&#x4F46;&#x5728;&#x540C;&#x4E00;&#x9879;&#x76EE;&#x5185;&#x9700;&#x7EDF;&#x4E00;&#x3002;</p>
<pre><code>/* Not recommended */
@import &quot;mixins/size&quot;;
@import &apos;mixins/grid.less&apos;;

/* Recommended */
@import &quot;mixins/size.less&quot;;
@import &quot;mixins/grid.less&quot;;
</code></pre><p><strong>&#x6DF7;&#x5165;&#xFF08;Mixin&#xFF09;</strong></p>
<ol>
<li>&#x5728;&#x5B9A;&#x4E49; mixin &#x65F6;&#xFF0C;&#x5982;&#x679C; mixin &#x540D;&#x79F0;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x7684; className&#xFF0C;&#x5FC5;&#x987B;&#x52A0;&#x4E0A;&#x62EC;&#x53F7;&#xFF0C;&#x5426;&#x5219;&#x5373;&#x4F7F;&#x4E0D;&#x88AB;&#x8C03;&#x7528;&#x4E5F;&#x4F1A;&#x8F93;&#x51FA;&#x5230; CSS &#x4E2D;&#x3002;</li>
<li>&#x5982;&#x679C;&#x6DF7;&#x5165;&#x7684;&#x662F;&#x672C;&#x8EAB;&#x4E0D;&#x8F93;&#x51FA;&#x5185;&#x5BB9;&#x7684; mixin&#xFF0C;&#x9700;&#x8981;&#x5728; mixin &#x540E;&#x6DFB;&#x52A0;&#x62EC;&#x53F7;&#xFF08;&#x5373;&#x4F7F;&#x4E0D;&#x4F20;&#x53C2;&#x6570;&#xFF09;&#xFF0C;&#x4EE5;&#x533A;&#x5206;&#x8FD9;&#x662F;&#x5426;&#x662F;&#x4E00;&#x4E2A; className&#x3002;</li>
</ol>
<pre><code>/* Not recommended */
.big-text {
  font-size: 2em;
}

h3 {
  .big-text;
  .clearfix;
}

/* Recommended */
.big-text() {
  font-size: 2em;
}

h3 {
  .big-text(); /* 1 */
  .clearfix(); /* 2 */
}
</code></pre><p><strong>&#x907F;&#x514D;&#x5D4C;&#x5957;&#x5C42;&#x7EA7;&#x8FC7;&#x591A;</strong></p>
<ul>
<li>&#x5C06;&#x5D4C;&#x5957;&#x6DF1;&#x5EA6;&#x9650;&#x5236;&#x5728;2&#x7EA7;&#x3002;&#x5BF9;&#x4E8E;&#x8D85;&#x8FC7;3&#x7EA7;&#x7684;&#x5D4C;&#x5957;&#xFF0C;&#x7ED9;&#x4E88;&#x91CD;&#x65B0;&#x8BC4;&#x4F30;&#x3002;&#x8FD9;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x51FA;&#x73B0;&#x8FC7;&#x4E8E;&#x8BE6;&#x5B9E;&#x7684;CSS&#x9009;&#x62E9;&#x5668;&#x3002;</li>
<li>&#x907F;&#x514D;&#x5927;&#x91CF;&#x7684;&#x5D4C;&#x5957;&#x89C4;&#x5219;&#x3002;&#x5F53;&#x53EF;&#x8BFB;&#x6027;&#x53D7;&#x5230;&#x5F71;&#x54CD;&#x65F6;&#xFF0C;&#x5C06;&#x4E4B;&#x6253;&#x65AD;&#x3002;&#x63A8;&#x8350;&#x907F;&#x514D;&#x51FA;&#x73B0;&#x591A;&#x4E8E;20&#x884C;&#x7684;&#x5D4C;&#x5957;&#x89C4;&#x5219;&#x51FA;&#x73B0;&#x3002;</li>
</ul>
<p><strong>&#x5B57;&#x7B26;&#x4E32;&#x63D2;&#x503C;</strong></p>
<p>&#x53D8;&#x91CF;&#x53EF;&#x4EE5;&#x7528;&#x7C7B;&#x4F3C;ruby&#x548C;php&#x7684;&#x65B9;&#x5F0F;&#x5D4C;&#x5165;&#x5230;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#xFF0C;&#x50CF;@{name}&#x8FD9;&#x6837;&#x7684;&#x7ED3;&#x6784;: @base-url: &quot;<a href="http://assets.fnord.com" target="_blank">http://assets.fnord.com</a>&quot;; background-image: url(&quot;@{base-url}/images/bg.png&quot;);</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="模块组织.html" class="navigation navigation-prev " aria-label="Previous page: 3.3 模块组织">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="性能优化.html" class="navigation navigation-next " aria-label="Next page: 3.5 性能优化">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.4 Less规范","level":"1.4.4","depth":2,"next":{"title":"3.5 性能优化","level":"1.4.5","depth":2,"path":"css/性能优化.md","ref":"css/性能优化.md","articles":[]},"previous":{"title":"3.3 模块组织","level":"1.4.3","depth":2,"path":"css/模块组织.md","ref":"css/模块组织.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"css/Less规范.md","mtime":"2019-05-16T03:10:52.750Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-17T02:26:20.307Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

